import time

from selenium.webdriver.common.by import By

class AddGoodsPage:
    # 定义后台登录函数
    def login(self, driver, username="admin123", password="admin123"):
        # 1、输入用户名
        # 定位
        element = driver.find_element(By.CSS_SELECTOR, '[name="username"]')
        # 操作
        element.clear()
        element.send_keys(username)
        time.sleep(2)
        # 2、输入密码
        element = driver.find_element(By.CSS_SELECTOR, '[name="password"]')
        # 操作
        element.clear()
        element.send_keys(password)
        # 3、点击登录
        element = driver.find_element(By.CSS_SELECTOR, '.el-button.el-button--primary.el-button--medium')
        element.click()